package 类变量;

public class Person {
    private int id;
    private static int total = 0;

    public static int getTotalPerson() {
        // id++;
        return total;
    }

    public Person() {
        total++;
        id = total;
    }
}

class TestPerson {
    public static void main(String[] args) {
        System.out.println("Number of total is " + Person.getTotalPerson());// 0
        Person p1 = new Person(); // total + 1
        System.out.println("Number of total is " + Person.getTotalPerson());// 1
    }
}
